home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume11 / musbus / part04 < prev    next >
Encoding:
Text File  |  1987-09-16  |  50.2 KB  |  2,115 lines

  1. Path: uunet!munnari!sources-request
  2. From: sources-request@munnari.oz
  3. Newsgroups: comp.sources.unix
  4. Subject: v11i032:  MUSBUS 5.0 -- Monash University Benchmark, Part04/04
  5. Message-ID: <1828@munnari.oz>
  6. Date: 17 Sep 87 08:21:03 GMT
  7. Sender: kre@munnari.oz
  8. Lines: 2104
  9. Approved: kre@munnari.oz.au
  10.  
  11. Submitted by: kenj@moncsbruce.oz.au (Ken McDonell)
  12. Posting-number: Volume 11, Issue 32
  13. Archive-name: musbus/Part04
  14.  
  15. #! /bin/sh
  16. # This is a shell archive, meaning:
  17. # 1. Remove everything above the #! /bin/sh line.
  18. # 2. Save the resulting text in a file.
  19. # 3. Execute the file with /bin/sh (not csh) to create the files:
  20. #    mem.c
  21. #    mk1
  22. #    mk2
  23. #    mkcomp
  24. #    mkdistrib
  25. #    mkinstall
  26. #    mkperm.c
  27. #    mkprofile
  28. #    mkscript
  29. #    mkscript.out
  30. #    mktbl
  31. #    musbus.1
  32. #    pipe.c
  33. #    precision.c
  34. #    run
  35. #    script.master
  36. #    spawn.c
  37. #    syscall.c
  38. #    tbl.1
  39. #    tbl.2
  40. #    tbl.3
  41. #    tbl.4
  42. #    tbl.5
  43. #    time.awk
  44. #    ttychk.c
  45. #    util.c
  46. # This archive created: Thu Sep 17 06:49:08 EST 1987
  47. export PATH; PATH=/bin:$PATH
  48. echo 'x - mem.c'
  49. if test -f 'mem.c'
  50. then
  51.     echo 'shar: over-writing existing file mem.c'
  52. fi
  53. sed 's/^X//' > mem.c <<'End-of-File-Grunt'
  54. X/*
  55. X * mem [ -ssize ] [ -niter ]
  56. X *
  57. X *  perform int array accesses
  58. X *  array size (if given) is in Kbytes, default is 8K
  59. X *  iter accesses of each type, default is iter=100000
  60. X *  Configuration options
  61. X *  #ifdef random    random access
  62. X *  #ifndef random    sequential access
  63. X *  #ifdef awk        output on stderr for benchmark script
  64. X *  #ifdef debug    output on stdout for diagnostics
  65. X *
  66. X *  #ifdef BSD4v1    4.1 BSD, ftime() exists
  67. X *  #ifdef BSD4v2    4.2 BSD, gettimeofday() exists
  68. X *  #ifdef SysV        System V, times() returns real time
  69. X *
  70. X *  $Header: mem.c,v 3.5 87/08/06 08:11:10 kenj Exp $
  71. X */
  72. X
  73. X#include <sys/types.h>
  74. X#include <sys/times.h>
  75. X#ifdef BSD4v1
  76. X#include <sys/timeb.h>
  77. X#endif
  78. X#ifdef BSD4v2
  79. X#include <sys/time.h>
  80. X#include <sys/resource.h>
  81. X#endif
  82. X#include <stdio.h>
  83. X
  84. Xmain(argc, argv)
  85. Xint argc;
  86. Xchar *argv[];
  87. X{
  88. X        int            *tab;
  89. X        register char   *p;
  90. X        register int    i;
  91. X        register int    j;
  92. X        register int    mask;
  93. X        register int    k;
  94. X    long             iter = 100000;
  95. X    int         size = 8*1024 / sizeof(int);
  96. X    struct tms    tbuffer;
  97. X    long        access[2];
  98. X    long        ohead[2];
  99. X#ifdef BSD4v1
  100. X    struct timeb    tbuf;
  101. X    int        msec;
  102. X#endif
  103. X#ifdef BSD4v2
  104. X    struct timeval    tbuf;
  105. X    struct timezone    tzone;
  106. X    struct rusage    rubuf;
  107. X    long        rusec, cpusec;
  108. X#endif
  109. X    char        *prog = argv[0];
  110. X        char            *malloc();
  111. X#ifdef random
  112. X    long        index[1000];
  113. X#endif
  114. X
  115. X        while (argc-- > 1) {
  116. X                switch (argv[1][1]) {
  117. X                case 's':
  118. X                        size = atoi(&argv[1][2])*1024 / sizeof(int);
  119. X                        break;
  120. X                case 'n':
  121. X                        iter = atoi(&argv[1][2]);
  122. X                        break;
  123. X                default:
  124. X                        printf("Usage: %s [-ssize] [-niter]\n", prog);
  125. X                        exit(1);
  126. X                }
  127. X                argv++;
  128. X        }
  129. X
  130. X        mask = size / sizeof(int);
  131. X
  132. X        if ((tab = (int *)malloc(size*sizeof(int))) == (int *)0) {
  133. X                printf("%s: malloc failed for %d bytes\n", prog, size*sizeof(int));
  134. X                exit(1);
  135. X        }
  136. X
  137. X#ifdef random
  138. X    /* build random array index map */
  139. X    for (i = 0; i < 1000; i++)
  140. X        index[i] = rand() % mask;
  141. X#endif
  142. X
  143. X        /* measure overhead for loop */
  144. X    srand(1);
  145. X#ifdef SysV
  146. X        ohead[0] = -times(&tbuffer);
  147. X    ohead[1] = -tbuffer.tms_utime - tbuffer.tms_stime;
  148. X#else
  149. X#ifdef BSD4v1
  150. X        times(&tbuffer);
  151. X    ftime(&tbuf);
  152. X    ohead[0] = -tbuf.time;
  153. X    msec = tbuf.millitm;
  154. X    ohead[1] = -tbuffer.tms_utime - tbuffer.tms_stime;
  155. X#else
  156. X#ifdef BSD4v2
  157. X    gettimeofday(&tbuf, &tzone);
  158. X    getrusage(RUSAGE_SELF, &rubuf);
  159. X#ifdef debug
  160. X    printf("real %d+%d user %d+%d sys %d+%d\n", tbuf.tv_sec, tbuf.tv_usec,
  161. X            rubuf.ru_utime.tv_sec, rubuf.ru_utime.tv_usec,
  162. X            rubuf.ru_stime.tv_sec, rubuf.ru_stime.tv_usec);
  163. X#endif
  164. X    ohead[0] = -tbuf.tv_sec;
  165. X    rusec = tbuf.tv_usec;
  166. X    ohead[1] = -rubuf.ru_utime.tv_sec - rubuf.ru_stime.tv_sec;
  167. X    cpusec = rubuf.ru_utime.tv_usec + rubuf.ru_stime.tv_usec;
  168. X#else
  169. X    What sort of Unix system if this?
  170. X#endif
  171. X#endif
  172. X#endif
  173. X        for (i = 0, k = 0; i < iter; i++) {
  174. X#ifdef random
  175. X                j = index[k];
  176. X        k++;
  177. X        if (k >= 1000) k = 0;
  178. X#else
  179. X        j = i % mask;
  180. X#endif
  181. X    }
  182. X#ifdef SysV
  183. X    ohead[0] += times(&tbuffer);
  184. X    ohead[1] += tbuffer.tms_utime + tbuffer.tms_stime;
  185. X#else
  186. X#ifdef BSD4v1
  187. X        times(&tbuffer);
  188. X    ftime(&tbuf);
  189. X    ohead[0] += tbuf.time;
  190. X    ohead[0] = ohead[0]*1000 + tbuf.millitm - msec;
  191. X    ohead[1] += tbuffer.tms_utime + tbuffer.tms_stime;
  192. X#else
  193. X#ifdef BSD4v2
  194. X    gettimeofday(&tbuf, &tzone);
  195. X    getrusage(RUSAGE_SELF, &rubuf);
  196. X#ifdef debug
  197. X    printf("real %d+%d user %d+%d sys %d+%d\n", tbuf.tv_sec, tbuf.tv_usec,
  198. X            rubuf.ru_utime.tv_sec, rubuf.ru_utime.tv_usec,
  199. X            rubuf.ru_stime.tv_sec, rubuf.ru_stime.tv_usec);
  200. X#endif
  201. X    ohead[0] += tbuf.tv_sec;
  202. X    ohead[0] = ohead[0]*1000 + (tbuf.tv_usec - rusec)/1000;
  203. X    ohead[1] += rubuf.ru_utime.tv_sec + rubuf.ru_stime.tv_sec;
  204. X    ohead[1] = ohead[1]*60 + 60*(rubuf.ru_utime.tv_usec + rubuf.ru_stime.tv_usec - cpusec)/1000000;
  205. X#endif
  206. X#endif
  207. X#endif
  208. X#ifdef debug
  209. X        printf("overhead real: %d msec cpu: %.1f sec\n", ohead[0], ((float)ohead[1])/60.);
  210. X#endif
  211. X        
  212. X        /* perform accesses */
  213. X    srand(1);
  214. X#ifdef SysV
  215. X        access[0] = -times(&tbuffer);
  216. X    access[1] = -tbuffer.tms_utime - tbuffer.tms_stime;
  217. X#else
  218. X#ifdef BSD4v1
  219. X        times(&tbuffer);
  220. X    ftime(&tbuf);
  221. X    access[0] = -tbuf.time;
  222. X    msec = tbuf.millitm;
  223. X    access[1] = -tbuffer.tms_utime - tbuffer.tms_stime;
  224. X#else
  225. X#ifdef BSD4v2
  226. X    gettimeofday(&tbuf, &tzone);
  227. X    getrusage(RUSAGE_SELF, &rubuf);
  228. X#ifdef debug
  229. X    printf("real %d+%d user %d+%d sys %d+%d\n", tbuf.tv_sec, tbuf.tv_usec,
  230. X            rubuf.ru_utime.tv_sec, rubuf.ru_utime.tv_usec,
  231. X            rubuf.ru_stime.tv_sec, rubuf.ru_stime.tv_usec);
  232. X#endif
  233. X    access[0] = -tbuf.tv_sec;
  234. X    rusec = tbuf.tv_usec;
  235. X    access[1] = -rubuf.ru_utime.tv_sec - rubuf.ru_stime.tv_sec;
  236. X    cpusec = rubuf.ru_utime.tv_usec + rubuf.ru_stime.tv_usec;
  237. X#endif
  238. X#endif
  239. X#endif
  240. X        for (i = 0, k = 0; i < iter; i++) {
  241. X#ifdef random
  242. X                j = tab[index[k]];
  243. X        k++;
  244. X        if (k >= 1000) k = 0;
  245. X#else
  246. X        j = tab[i % mask];
  247. X#endif
  248. X    }
  249. X#ifdef SysV
  250. X    access[0] += times(&tbuffer);
  251. X    access[1] += tbuffer.tms_utime + tbuffer.tms_stime;
  252. X#else
  253. X#ifdef BSD4v1
  254. X        times(&tbuffer);
  255. X    ftime(&tbuf);
  256. X    access[0] += tbuf.time;
  257. X    access[0] = access[0]*1000 + tbuf.millitm - msec;
  258. X    access[1] += tbuffer.tms_utime + tbuffer.tms_stime;
  259. X#else
  260. X#ifdef BSD4v2
  261. X    gettimeofday(&tbuf, &tzone);
  262. X    getrusage(RUSAGE_SELF, &rubuf);
  263. X#ifdef debug
  264. X    printf("real %d+%d user %d+%d sys %d+%d\n", tbuf.tv_sec, tbuf.tv_usec,
  265. X            rubuf.ru_utime.tv_sec, rubuf.ru_utime.tv_usec,
  266. X            rubuf.ru_stime.tv_sec, rubuf.ru_stime.tv_usec);
  267. X#endif
  268. X    access[0] += tbuf.tv_sec;
  269. X    access[0] = access[0]*1000 + (tbuf.tv_usec - rusec)/1000;
  270. X    access[1] += rubuf.ru_utime.tv_sec + rubuf.ru_stime.tv_sec;
  271. X    access[1] = access[1]*60 + 60*(rubuf.ru_utime.tv_usec + rubuf.ru_stime.tv_usec - cpusec)/1000000;
  272. X#endif
  273. X#endif
  274. X#endif
  275. X#ifdef awk
  276. X    fprintf(stderr, "%d %d %.3f\n", iter, access[0] - ohead[0],
  277. X            ((float)(access[1] - ohead[1]))/60.);
  278. X#endif
  279. X#ifdef debug
  280. X        printf("total real: %d msec cpu: %.1f sec\n", access[0], ((float)access[1])/60.);
  281. X    printf("access real: %d msec cpu: %.1f sec\n", access[0] - ohead[0],
  282. X            ((float)(access[1] - ohead[1]))/60.);
  283. X        printf("%d Kbyte array: %.1f accesses per second\n", size*sizeof(int)/1024,
  284. X                iter*1000.0/((float)(access[0] - ohead[0])));
  285. X#endif
  286. X
  287. X    exit(0);
  288. X}
  289. End-of-File-Grunt
  290. if test 6343 -ne `cat 'mem.c' | wc -c`
  291. then
  292.     echo 'shar: transmission error (expected 6343 characters)'
  293. fi
  294. echo 'x - mk1'
  295. if test -f 'mk1'
  296. then
  297.     echo 'shar: over-writing existing file mk1'
  298. fi
  299. sed 's/^X//' > mk1 <<'End-of-File-Grunt'
  300. X#! /bin/sh
  301. X# Common premable for mktbl and mkcomp
  302. X# $Header: mk1,v 1.3 87/06/24 13:40:55 kjmcdonell Beta $
  303. Xif test ! -f log.$2
  304. Xthen
  305. X    if test ! -f ../Results/log.$2
  306. X    then
  307. X        echo "$1: cannot open MUSBUS log file \"log.$2\""
  308. X        exit 1
  309. X    else
  310. X        log=../Results/log.$2
  311. X    fi
  312. X    else
  313. X        log=log.$2
  314. Xfi
  315. Xif grep '^MC=' $log >/dev/null
  316. Xthen
  317. X    :
  318. Xelse
  319. X    ./Config $log >/dev/tty
  320. Xfi
  321. Xif grep 'arithoh' $log >/dev/null
  322. Xthen
  323. X    if grep '(Actual' $log >/dev/null
  324. X    then
  325. X        :
  326. X    else
  327. X        ./Adjust $log
  328. X    fi
  329. Xfi
  330. Xecho "log=$log"
  331. Xawk '
  332. X/^[A-Z][A-Z]*=/            { print; next }
  333. X/^Start Benchmark Run \(... /    { print "V=\"3.0\""
  334. X                  print "D=\"",$6,$5,$9,"\""
  335. X                  exit }
  336. X/^Start Benchmark \(Version/    { print "V=\"",$4,"\""
  337. X                  print "D=\"",$8,$7,$11,"\""
  338. X                  exit }
  339. X/^Start Benchmark Run \(MUSBUS/    { print "V=\"",$6,"\""
  340. X                  nextdate=1
  341. X                  next }
  342. Xnextdate==1            { print "D=\"",$3,$2,$6,"\""
  343. X                  exit }
  344. X' $log \
  345. X| sed \
  346. X    -e 's/\(V="[^"]*\))/\1/g' \
  347. X    -e 's/,//g' \
  348. X    -e 's/"  */"/g' \
  349. X    -e 's/  *"/"/g'
  350. Xexit 0
  351. End-of-File-Grunt
  352. if test 980 -ne `cat 'mk1' | wc -c`
  353. then
  354.     echo 'shar: transmission error (expected 980 characters)'
  355. fi
  356. echo 'x - mk2'
  357. if test -f 'mk2'
  358. then
  359.     echo 'shar: over-writing existing file mk2'
  360. fi
  361. sed 's/^X//' > mk2 <<'End-of-File-Grunt'
  362. X#! /bin/sh
  363. X# extract goodies from the log file
  364. X# $Header: mk2,v 1.3 87/08/07 15:40:36 kenj Exp $
  365. Xawk '
  366. X/^$/            { next }
  367. X/^[A-Z][A-Z]*=/        { next }
  368. X/Benchmark/        { next }
  369. X/Disk Problem/        { next }
  370. X/C Compiler Test/    { next }
  371. X/iterations/        { next }
  372. X/interactive users/    { next }
  373. X/loop < ohead:/        { next }
  374. X/Synthetic Work/    { mem=0; next }
  375. X/Simulated Work/    { mem=0; next }
  376. X/Simulated Multi-user/    { mem=0; next }
  377. X/type = arithoh/    { tbl=1; t="Loop Overhead"; next }
  378. X/type = register/    { tbl=1; t="Register Arithmetic"; next }
  379. X/type = short/        { tbl=1; t="Short Arithmetic"; next }
  380. X/type = int/        { tbl=1; t="Integer Arithmetic"; next }
  381. X/type = long/        { tbl=1; t="Long Arithmetic"; next }
  382. X/type = float/        { tbl=1; t="Float Arithmetic"; next }
  383. X/type = double/        { tbl=1; t="Double Arithmetic"; next }
  384. X/sqrt/            { tbl=1; t="dc sqrt(2)"; und=1; next }
  385. X/Hanoi/            { tbl=1; t="Recursion"; next }
  386. X/System Call/        { tbl=1; t="System Calls"; und=1; next }
  387. X/Pipe Throughput/    { tbl=1; t="Pipe Throughput"; next }
  388. X/Pipe-based Context/    { tbl=1; t="Pipes & Context Switching"; next }
  389. X/Signal-based Context/    { tbl=1; t="Signals & Context Switching"; next }
  390. X/Process Creation/    { tbl=1; t="Process Create"; next }
  391. X/Execl/            { tbl=1; t="Execing"; next }
  392. X/cc -c.* cctest.c/    { tbl=1; t="C Compile"; und=1; next }
  393. X/cc -c.* fstime.c/    { tbl=1; t="C Compile"; und=1; next }
  394. X/cc cctest.o/        { tbl=1; t="C Load"; next }
  395. X/cc fstime.o/        { tbl=1; t="C Load"; next }
  396. X/^[0-9]+ Concurrent/    { tbl=5; t=$1 "_Users"; next}
  397. X/Elapsed/ && /Actual/    { e=$(NF-1); next }
  398. X/Elapsed/        { e=$3; next }
  399. X/CPU/ && /Actual/    { c=$(NF-1)
  400. X              if (intbl != tbl) {
  401. X                if (intbl) print ".TE\n.)b"
  402. X                printf ".so tbl.%d\n",tbl
  403. X                intbl=tbl
  404. X              }
  405. X              if (und) { print "_"; und=0 }
  406. X              printf "%s\t%.2f\t%.2f\n",t,e,c
  407. X              t=""
  408. X              next
  409. X            }
  410. X/CPU/ && mem==0        { c=$3
  411. X              if (intbl != tbl) {
  412. X                if (intbl) print ".TE\n.)b"
  413. X                printf ".so tbl.%d\n",tbl
  414. X                intbl=tbl
  415. X              }
  416. X              if (und) { print "_"; und=0 }
  417. X              printf "%s\t%.2f\t%.2f\n",t,e,c
  418. X              t=""
  419. X              next
  420. X            }
  421. X/CPU/ && mem!=0        { next }
  422. X/Sequential Memory/    { mem=1; found++;
  423. X              if (intbl != 2) {
  424. X                if (intbl) print ".TE\n.)b"
  425. X                print ".so tbl.2"
  426. X                    intbl=2
  427. X              }
  428. X              next
  429. X            }
  430. X/Random Memory/        { mem=2; found++; tbl=2
  431. X              if (intbl != 2) {
  432. X                if (intbl) print ".TE\n.)b"
  433. X                printf ".so tbl.2"
  434. X                    intbl=2
  435. X              }
  436. X              next
  437. X            }
  438. X/Array Size/        { size=$3; next }
  439. X/Real Rate/         { if (mem==1) s[size]=$3/1000
  440. X              if (mem==2) r[size]=$3/1000
  441. X              if (found==2) {
  442. X                  printf "%d\t%.2f\t%.2f\n",size,s[size],r[size]
  443. X                  if (size==512) {
  444. X                      mem=0
  445. X                      found=0
  446. X                  }
  447. X              }
  448. X              next
  449. X            }
  450. X/Filesystem Throughput/    { if (intbl) print ".TE\n.)b"
  451. X              print ".so tbl.3"
  452. X              print ".so disks"
  453. X              print ".so tbl.4"
  454. X              intbl=4
  455. X              next }
  456. X/File Size/        { printf "%sK bytes",$3; next }
  457. X/Write:/        { printf "\t%.2f",$2; next }
  458. X/Read:/            { printf "\t%.2f",$2; next }
  459. X/Copy:/            { printf "\t%.2f",$2; print ""; next }
  460. X/\/dev/ || /tty/ || /used/ || /[dD]irector/ || /wallclock/    { next }
  461. X/^[^     ][^     ]*:\/[^     ]/    { next }    # df for NFS mounted filesystem
  462. X            { print $0 }
  463. XEND            { if (intbl) print ".TE\n.)b" }
  464. X' $1
  465. End-of-File-Grunt
  466. if test 3138 -ne `cat 'mk2' | wc -c`
  467. then
  468.     echo 'shar: transmission error (expected 3138 characters)'
  469. fi
  470. echo 'x - mkcomp'
  471. if test -f 'mkcomp'
  472. then
  473.     echo 'shar: over-writing existing file mkcomp'
  474. fi
  475. sed 's/^X//' > mkcomp <<'End-of-File-Grunt'
  476. X#! /bin/sh
  477. X# $Header: mkcomp,v 1.3 87/09/17 06:08:30 kenj Exp $
  478. X# Make tbl source for pairwise machine comparison.
  479. Xprog=$0
  480. Xif test $# -ne 2
  481. Xthen
  482. X    echo "Usage: $prog machine compared-to"
  483. X    exit 1
  484. Xfi
  485. Xout=$1-$2
  486. Xfor x in 1 2
  487. Xdo
  488. X    init=`./mk1 $prog $1`
  489. X    test $? != 0 && echo "$init" && exit 1
  490. X    test $x = 1 && shift
  491. X    init=`echo $init | sed "s/=/$x=/g"`
  492. X    eval $init
  493. Xdone
  494. Xcat >$out <<End-of-File-Grunt
  495. X.\" \$Compile: typeset -me -t %f
  496. X.nr tf 0
  497. X.nr tp 10
  498. X.nr pp 10
  499. X.nr fp 10
  500. X.ll 6.5i
  501. X.sz 10
  502. X.he 'MUSBUS'Monash UNIX Benchmarking Suite''
  503. X.fo '$MC1 \- $MC2''\*(td'
  504. X.(b
  505. X.TS
  506. Xdoublebox,center;
  507. Xl | c | c
  508. Xl | l | l.
  509. X    This System    Relative To
  510. X_
  511. XProcessor    $MC1    $MC2
  512. X    $OPT1    $OPT2
  513. XMemory    $MEM1    $MEM2
  514. XUNIX Version    $UNIX1    $UNIX2
  515. XTest Date    $D1    $D2
  516. XMUSBUS Version    $V1    $V2
  517. X.TE
  518. X.)b
  519. XEnd-of-File-Grunt
  520. X
  521. X./mk2 $log2 \
  522. X| sed \
  523. X    -e '/^_$/d' \
  524. X    -e '/^\.so /d' \
  525. X    -e '/^\.TE/d' \
  526. X    -e '/^\.)b/d' \
  527. X    -e 's/^\([^    ]*    \)\(.*\)/\/^\1\/s\/$\/    \2\//' \
  528. X  > tmp.$$
  529. X
  530. Xecho "Disks    $DISKS1    $DISKS2" > disks
  531. X./mk2 $log1 \
  532. X| sed -f tmp.$$ \
  533. X| awk '
  534. XBEGIN { FS="    " }
  535. X/tbl.1/    { inv = 0 }
  536. X/tbl.2/    { inv = 1 }
  537. X/tbl.3/    { inv = 1 }
  538. X/tbl.5/    { inv = 0 }
  539. X/[0-9]\.[0-9]/ && NF==5 {
  540. X    printf $1;
  541. X    r2 = r1 = "\\*(if"
  542. X    if (!inv) {
  543. X        if ($2) r1 = $4/$2
  544. X        if ($3) r2 = $5/$3
  545. X    }
  546. X    else {
  547. X        if ($4) r1 = $2/$4
  548. X        if ($5) r2 = $3/$5
  549. X    }
  550. X    printf "\t%.2f\t%.2f\t%.2f\t%.2f\n",$2,$3,r1,r2
  551. X    next
  552. X}
  553. X/[0-9]\.[0-9]/ && NF==7 {
  554. X    printf $1;
  555. X    if (!inv) {
  556. X        if ($2) r1 = $5/$2
  557. X        if ($3) r2 = $6/$3
  558. X        if ($4) r3 = $7/$4
  559. X    }
  560. X    else {
  561. X        if ($5) r1 = $2/$5
  562. X        if ($6) r2 = $3/$6
  563. X        if ($7) r3 = $4/$7
  564. X    }
  565. X    printf "\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\n",$2,$3,$4,r1,r2,r3
  566. X    next;
  567. X}
  568. X/[0-9]\.[0-9]/ { printf "%s\t?\t?\t?\t?\n",$1; next }
  569. X{ print }' \
  570. X| sed \
  571. X    -e 's/^\.so tbl\./.so comptbl./' \
  572. X    -e 's/^\([1-9][0-9]*\)_Users/\1/' \
  573. X| soelim >>$out
  574. Xrm -f disks tmp.$$
  575. End-of-File-Grunt
  576. if test 1792 -ne `cat 'mkcomp' | wc -c`
  577. then
  578.     echo 'shar: transmission error (expected 1792 characters)'
  579. fi
  580. echo 'x - mkdistrib'
  581. if test -f 'mkdistrib'
  582. then
  583.     echo 'shar: over-writing existing file mkdistrib'
  584. fi
  585. sed 's/^X//' > mkdistrib <<'End-of-File-Grunt'
  586. X#! /bin/sh
  587. X# Package things up ready for a distribution
  588. X# $Header: mkdistrib,v 1.4 87/09/10 05:09:28 kenj Exp $
  589. X
  590. Xmake purge
  591. X
  592. Xfor dir in *
  593. Xdo
  594. X    test -d $dir -a $dir != "RCS" || continue
  595. X    cd $dir
  596. X    if test "`echo *`" != '*'
  597. X    then
  598. X        if test -f Makefile
  599. X        then
  600. X            make clean
  601. X        fi
  602. X        for file in *
  603. X        do
  604. X            test -f "../$file" || continue
  605. X            ver=1
  606. X            while test -f ../$file,$ver
  607. X            do
  608. X                ver=`expr $ver + 1`
  609. X            done
  610. X            mv $file $file,$ver
  611. X        done
  612. X        ls * >../$dir.files
  613. X        mv * ..
  614. X    fi
  615. X    cd ..
  616. X    rmdir $dir
  617. Xdone
  618. X
  619. Xrm -rf Tmp
  620. End-of-File-Grunt
  621. if test 509 -ne `cat 'mkdistrib' | wc -c`
  622. then
  623.     echo 'shar: transmission error (expected 509 characters)'
  624. fi
  625. echo 'x - mkinstall'
  626. if test -f 'mkinstall'
  627. then
  628.     echo 'shar: over-writing existing file mkinstall'
  629. fi
  630. sed 's/^X//' > mkinstall <<'End-of-File-Grunt'
  631. X#! /bin/sh
  632. X# Undo the flattening done by mkdistrib.
  633. X# $Header: mkinstall,v 1.3 87/09/10 05:08:45 kenj Exp $
  634. Xfor list in *.files
  635. Xdo
  636. X    if test "$list" = '*.files'
  637. X    then
  638. X    continue
  639. X    fi
  640. X    dir=`echo $list | sed 's/.files//'`
  641. X    test -d $dir || mkdir $dir
  642. X    mv `cat $list` $dir
  643. X    cd $dir
  644. X    for file in *
  645. X    do
  646. X    case $file
  647. X    in
  648. X        *,[0-9])
  649. X            mv $file `echo $file | sed 's/,[0-9]$//'`
  650. X            ;;
  651. X    esac
  652. X    done
  653. X    cd ..
  654. X    rm -f $list
  655. Xdone
  656. X
  657. Xtest -d Tmp || mkdir Tmp
  658. End-of-File-Grunt
  659. if test 471 -ne `cat 'mkinstall' | wc -c`
  660. then
  661.     echo 'shar: transmission error (expected 471 characters)'
  662. fi
  663. echo 'x - mkperm.c'
  664. if test -f 'mkperm.c'
  665. then
  666.     echo 'shar: over-writing existing file mkperm.c'
  667. fi
  668. sed 's/^X//' > mkperm.c <<'End-of-File-Grunt'
  669. X#include <stdio.h>
  670. X#ifndef lint
  671. Xstatic char RCSid[] = "$Header: mkperm.c,v 1.2 87/06/22 14:32:26 kjmcdonell Beta $";
  672. X#endif
  673. X
  674. X/* undefine rand and srand if you don't have random() from USENET */
  675. X#define rand random
  676. X#define srand srandom
  677. X
  678. Xmain(argc, argv)
  679. Xint    argc;
  680. Xchar    *argv[];
  681. X{
  682. X    int    n;    /* generate a permutation of {1,2,3,...,n} */
  683. X    int    i;
  684. X    int    t;
  685. X    char    *mask;
  686. X
  687. X    if (argc > 2 && strcmp(argv[1], "-s") == 0) {
  688. X        t = atoi(argv[2]);
  689. X        if (t < 16)
  690. X            t = 1 << t;
  691. X        srand(t);
  692. X        argv++;
  693. X        argv++;
  694. X    }
  695. X    n = atoi(argv[1]);
  696. X    mask = (char *)malloc(n);
  697. X
  698. X    for (i=0; i<n; i++)
  699. X        mask[i] = '\0';
  700. X    for (i=0; i<n; i++) {
  701. X        do {
  702. X            t = rand() % n;
  703. X        } while (mask[t]);
  704. X        mask[t] = '\1';
  705. X        printf("%d ", t+1);
  706. X    }
  707. X    putchar('\n');
  708. X    exit(0);
  709. X}
  710. End-of-File-Grunt
  711. if test 724 -ne `cat 'mkperm.c' | wc -c`
  712. then
  713.     echo 'shar: transmission error (expected 724 characters)'
  714. fi
  715. echo 'x - mkprofile'
  716. if test -f 'mkprofile'
  717. then
  718.     echo 'shar: over-writing existing file mkprofile'
  719. fi
  720. sed 's/^X//' > mkprofile <<'End-of-File-Grunt'
  721. X#! /bin/sh
  722. X# Incomplete.
  723. X# $Header: mkprofile,v 1.2 87/06/23 17:07:28 kjmcdonell Beta $
  724. X    profilework)       
  725. X            echo ""
  726. X            echo "Profile Work Load Test:" >>$LOG
  727. X            rate=${rate-2}
  728. X            echo "" >>$LOG
  729. X            echo "Control parameters: rate=$rate script=script.1" >>$LOG
  730. X            echo "" >>$LOG
  731. X            if test ! -f makework
  732. X            then
  733. X                make makework
  734. X            fi
  735. X            if test ! -f keyb
  736. X            then
  737. X                make keyb
  738. X            fi
  739. X            tty=${tty-`tty`}
  740. X            if test "$tty" = "not a tty"
  741. X            then
  742. X            tty=/dev/tty
  743. X            fi
  744. X            chmod +w script.1
  745. X            ed - script.1 <<EOF
  746. Xg/^R=/s/=.*/=$rate/
  747. Xg/^C=/s,=.*,=$tty,
  748. Xg/^H=/s,=.*,=.,
  749. Xg/PATH=/s,=[^:]*:,=`pwd`:,
  750. Xw
  751. Xq
  752. XEOF
  753. X            chmod -w script.1
  754. X            log=`pwd`/log.profile
  755. X            ( echo "export log;log=$log" ; sed \
  756. X-e 's/^export/##&/' \
  757. X-e 's/^cd/##&/' \
  758. X-e 's,^\([^:][a-zA-Z0-9./]*\)[     ].*,time sh -cx '"'&'"' 2>>$log,' \
  759. X-e "s/\('[^$][^$][^']*\)"'\$\$'"/\1'"'$$'"'/g" \
  760. X-e "s/\('[^$][^$][^']*\)"'\$\$'"/\1'"'$$'"'/g" \
  761. X-e "s/\('[^$][^$][^']*\)"'\$\$'"/\1'"'$$'"'/g" \
  762. X-e "s/''//g" \
  763. X-e 's/^##//' \
  764. X-e 's/^\([a-zA-Z][a-zA-Z0-9]*\)=/export \1;&/' script.1 ) >script.1.time
  765. X            s=`cat script.1 | wc -c`
  766. X            ts=`cat script.1.time | wc -c`
  767. X            rate=`echo "scale=2;$rate*$ts/$s" | bc`
  768. X            ed - script.1.time << End-of-File
  769. Xg/R=/s/=.*/=$rate/
  770. Xw
  771. Xq
  772. XEnd-of-File
  773. X            echo "Profile run starts ..."
  774. X            echo '/bin/sh -ie <script.1.time' >./Workload/workload.time
  775. X            trap "./cleanup -w -i $i -t $tmp -a; exit" 1 2 3 4 5 6 7 8 9 10 12 13 14 15
  776. X            time ./makework -rc $rate $tty 1 <./Workload/workload.time >$tty 2>>$tmp
  777. X            if test $? != 0
  778. X            then
  779. X#             makework was aborted
  780. X            cp $tmp Tmp/save.$n.abort
  781. X            ./cleanup -w -i $i -t $tmp -a
  782. X            exit
  783. X            fi
  784. X            ./cleanup -w -t $tmp
  785. X            echo "" >>$LOG
  786. X            echo "Profile run finished, collect and summarize results ..."
  787. X            sed \
  788. X-e 's/[     ]*\([0-9][0-9]*\.[0-9]*\)  *real/real   \1\
  789. X/' \
  790. X-e 's/[     ]*\([0-9][0-9]*\.[0-9]*\)  *user/user   \1\
  791. X/' \
  792. X-e 's/[     ]*\([0-9][0-9]*\.[0-9]*\)  *sys/sys    \1\
  793. X/' \
  794. X                $log \
  795. X            | awk '
  796. XBEGIN    { printf "\t Real (percent)\t User (percent)\t  Sys (percent)\n" }
  797. X/^\+/    { if ($2 != "keyb") {
  798. X        c=$2
  799. X        cmd[c]=c
  800. X      }
  801. X      next
  802. X    }
  803. X/^real/    { r[c]+=$2; totr+=$2; }
  804. X/^user/    { u[c]+=$2; totu+=$2; }
  805. X/^sys/    { s[c]+=$2; tots+=$2; }
  806. XEND    { for (c in cmd) {
  807. X          printf cmd[c]
  808. X          printf "\t%6.1f (%5.2f%%)",r[c],100*r[c]/totr
  809. X          printf "\t%6.1f (%5.2f%%)",u[c],100*u[c]/totu
  810. X          printf "\t%6.1f (%5.2f%%)\n",s[c],100*s[c]/tots
  811. X      }
  812. X      printf "-------\n"
  813. X      printf "Totals:\t%6.1f\t\t%6.1f\t\t%6.1f\n",totr,totu,tots
  814. X    } ' >>$LOG
  815. X            ;;
  816. X
  817. End-of-File-Grunt
  818. if test 2568 -ne `cat 'mkprofile' | wc -c`
  819. then
  820.     echo 'shar: transmission error (expected 2568 characters)'
  821. fi
  822. echo 'x - mkscript'
  823. if test -f 'mkscript'
  824. then
  825.     echo 'shar: over-writing existing file mkscript'
  826. fi
  827. sed 's/^X//' > mkscript <<'End-of-File-Grunt'
  828. X#! /bin/sh
  829. X# $Header: mkscript,v 1.2 87/06/22 14:35:54 kjmcdonell Beta $
  830. X# create script files by permuting the job steps ..
  831. X# output files labelled script.n, n=1,2,...
  832. X
  833. Xif test $# -ne 2
  834. Xthen
  835. X    echo "Usage: mkscript n master-script"
  836. X    exit 1
  837. Xfi
  838. X
  839. Xn=$1
  840. Xshift
  841. X
  842. Xif test ! -f $1
  843. Xthen
  844. X    echo "mkscript: cannot open \"$1\""
  845. X    exit 1
  846. Xfi
  847. X
  848. Xns=`grep '^%%' $1 | wc -l`
  849. Xns=`expr $ns - 1`
  850. X
  851. Xk=1
  852. Xwhile test $k -le $n
  853. Xdo
  854. X    awk '
  855. XBEGIN    { '"`./mkperm -s $k $ns | sed 's/[0-9][0-9]*/perm[i++] = &;/g`"' nj=0 }
  856. XNR==1    { next }
  857. X/^%%/    { nj++; next }
  858. X    { if (job[nj] == "")
  859. X        job[nj] = $0
  860. X      else
  861. X        job[nj] = job[nj] "\n" $0
  862. X    }
  863. XEND    { print job[0]
  864. X      for (i=0; i<'$ns'; i++)
  865. X        print job[perm[i]]
  866. X      print job[nj]
  867. X    }' $1 > script.$k
  868. X    k=`expr $k + 1`
  869. Xdone
  870. End-of-File-Grunt
  871. if test 722 -ne `cat 'mkscript' | wc -c`
  872. then
  873.     echo 'shar: transmission error (expected 722 characters)'
  874. fi
  875. echo 'x - mkscript.out'
  876. if test -f 'mkscript.out'
  877. then
  878.     echo 'shar: over-writing existing file mkscript.out'
  879. fi
  880. sed 's/^X//' > mkscript.out <<'End-of-File-Grunt'
  881. X#! /bin/sh
  882. X# try running a script a catching the output
  883. X# $Header: mkscript.out,v 1.3 87/06/24 15:13:57 kjmcdonell Beta $
  884. Xcmdline=`sed 1q script.master | grep '^%W%' | sed 's/%W%[     ]*//'`
  885. Xif test "$cmdline" = ""
  886. Xthen
  887. X    echo "mkscript.out: illegal %W% record at beginning of \"script.master\""
  888. X    exit 1
  889. Xfi
  890. X
  891. Xmake clean context
  892. Xtty=/dev/null ; export tty
  893. Xmkdir .tmp
  894. Xcp * .tmp
  895. Xcd .tmp
  896. Xsed -e 1d -e '/^%%/d' script.master > script.1
  897. Xif $cmdline <script.1 >script.out 2>&1
  898. Xthen
  899. X    :
  900. Xelse
  901. X    cat script.out
  902. X    echo "mkscript.out: fatal error"
  903. X    exit 1
  904. Xfi
  905. Xcat script.1 >>script.out
  906. Xmv script.out ..
  907. Xcd ..
  908. Xrm -rf .tmp
  909. End-of-File-Grunt
  910. if test 606 -ne `cat 'mkscript.out' | wc -c`
  911. then
  912.     echo 'shar: transmission error (expected 606 characters)'
  913. fi
  914. echo 'x - mktbl'
  915. if test -f 'mktbl'
  916. then
  917.     echo 'shar: over-writing existing file mktbl'
  918. fi
  919. sed 's/^X//' > mktbl <<'End-of-File-Grunt'
  920. X#! /bin/sh
  921. X# $Header: mktbl,v 1.4 87/09/17 06:10:39 kenj Exp $
  922. X# make tbl source to summarize results.
  923. Xprog=$0
  924. Xif test $# -ne 1
  925. Xthen
  926. X    echo Usage: $prog machine
  927. X    exit 1
  928. Xfi
  929. Xinit=`./mk1 $prog $1`
  930. Xtest $? != 0 && echo "$init" && exit 1
  931. Xeval $init
  932. Xcat >$1 <<End-of-File-Grunt
  933. X.\" \$Compile: typeset -me -t %f
  934. X.nr tf 0
  935. X.nr tp 10
  936. X.nr pp 10
  937. X.nr fp 10
  938. X.ll 6.5i
  939. X.sz 10
  940. X.he 'MUSBUS'Monash UNIX Benchmarking Suite''
  941. X.fo '$MC''\*(td'
  942. X.(b
  943. X.TS
  944. Xdoublebox,center;
  945. Xl | l.
  946. XProcessor    $MC
  947. X    $OPT
  948. XMemory    $MEM
  949. XUNIX Version    $UNIX
  950. XTest Date    $D
  951. XMUSBUS Version    $V
  952. X.TE
  953. X.)b
  954. XEnd-of-File-Grunt
  955. Xecho "Disks: $DISKS" > disks
  956. X./mk2 $log \
  957. X| soelim \
  958. X| sed 's/^\([1-9][0-9]*\)_Users/\1/' >>$1
  959. Xrm -f disks
  960. End-of-File-Grunt
  961. if test 669 -ne `cat 'mktbl' | wc -c`
  962. then
  963.     echo 'shar: transmission error (expected 669 characters)'
  964. fi
  965. echo 'x - musbus.1'
  966. if test -f 'musbus.1'
  967. then
  968.     echo 'shar: over-writing existing file musbus.1'
  969. fi
  970. sed 's/^X//' > musbus.1 <<'End-of-File-Grunt'
  971. X.\" $Header: musbus.1,v 1.1 87/09/03 06:13:59 kenj Exp $
  972. X.TH MUSBUS 1
  973. X.SH NAME
  974. XMUSBUS \- a multi-user performance evaluation tool
  975. X.SH SYNOPSIS
  976. X.B run
  977. X.ft R
  978. X[ option ]
  979. X.SH DESCRIPTION
  980. XMUSBUS is designed to support multi-user performance measurements
  981. Xthat are both realistic and comparable between machines
  982. Xand systems.
  983. XThe principal performance metric is the time (CPU and elapsed)
  984. Xrequired to perform a selected workload as a function
  985. Xof increasing concurrent load.
  986. X.PP
  987. XA description of the workload profile is one of the
  988. Xinputs to MUSBUS, and consequently MUSBUS is a benchmarking
  989. Xtool, rather than a benchmark
  990. X.I per se.
  991. X.PP
  992. XIn addition to the multi-user test, MUSBUS supports a battery
  993. Xof smaller tests designed to measure some aspect of hardware
  994. Xspeed or system implementation efficiency.
  995. XThese are diagnostic, rather than performance, tests.
  996. X.PP
  997. XEach MUSBUS execution is controlled by a collection
  998. Xof environment variables and the script
  999. X.I run
  1000. Xthat performs error checking, repeated tests for statistical
  1001. Xvalidity, set up and clean up.
  1002. XParticular tests may be selected by options in the command line.
  1003. X.SH FILES
  1004. X.ta 12n
  1005. XWorkload/*    workload description
  1006. X.br
  1007. XTmp/*    temporary files
  1008. X.br
  1009. XResults/*    log files
  1010. X.br
  1011. XTools/*    ancillary support tools
  1012. X.SH DIAGNOSTICS
  1013. X``Benchmark Aborted'' and associated bad news indicating why.
  1014. X.SH "SEE ALSO"
  1015. XKen J. McDonell:
  1016. X.ft I
  1017. XAn Introduction to the Monash Benchmark Suite (MUSBUS),
  1018. X.ft R
  1019. X(included in the MUSBUS distribution).
  1020. X.br
  1021. XKen J. McDonell:
  1022. X.ft I
  1023. XTaking Performance Evaluation Out of the ``Stone Age'',
  1024. X.ft R
  1025. XProceedings Summer Usenix Technical Conference,
  1026. XPhoenix, Arizona, June, 1987, pp 407-417.
  1027. End-of-File-Grunt
  1028. if test 1639 -ne `cat 'musbus.1' | wc -c`
  1029. then
  1030.     echo 'shar: transmission error (expected 1639 characters)'
  1031. fi
  1032. echo 'x - pipe.c'
  1033. if test -f 'pipe.c'
  1034. then
  1035.     echo 'shar: over-writing existing file pipe.c'
  1036. fi
  1037. sed 's/^X//' > pipe.c <<'End-of-File-Grunt'
  1038. X/*
  1039. X *  pipe  -- test single process pipe throughput (no context switching)
  1040. X *
  1041. X *  $Header: pipe.c,v 3.5 87/06/22 14:32:36 kjmcdonell Beta $
  1042. X */
  1043. X
  1044. Xmain(argc, argv)
  1045. Xint    argc;
  1046. Xchar    *argv[];
  1047. X{
  1048. X    char    buf[512];
  1049. X    int    iter = 2048;    /* 1M byte */
  1050. X    int    pvec[2];
  1051. X
  1052. X    pipe(pvec);
  1053. X    close(0); dup(pvec[0]); close(pvec[0]);
  1054. X    close(1); dup(pvec[1]); close(pvec[1]);
  1055. X
  1056. X    while (iter-- > 0) {
  1057. X        if (write(1, buf, sizeof(buf)) != sizeof(buf))
  1058. X            perror("write failed");
  1059. X        if (read(0, buf, sizeof(buf)) != sizeof(buf))
  1060. X            perror("read failed");
  1061. X    }
  1062. X    exit(0);
  1063. X}
  1064. End-of-File-Grunt
  1065. if test 534 -ne `cat 'pipe.c' | wc -c`
  1066. then
  1067.     echo 'shar: transmission error (expected 534 characters)'
  1068. fi
  1069. echo 'x - precision.c'
  1070. if test -f 'precision.c'
  1071. then
  1072.     echo 'shar: over-writing existing file precision.c'
  1073. fi
  1074. sed 's/^X//' > precision.c <<'End-of-File-Grunt'
  1075. X/* Program to determine properties of the arithmetic available. */
  1076. X/* Makes certain assumptions about the likely format of numbers */
  1077. X/*                                */
  1078. X/* Author: Steven Pemberton, CWI, Amsterdam. steven@mcvax    */
  1079. X/*                                */
  1080. X/* If your C system is not unix but does have signal/setjmp,    */
  1081. X/*    add a #define unix                    */
  1082. X/* You may also need to change the #include <sys/signal.h> line */
  1083. X/*    and add some calls to signal().                */
  1084. X/*
  1085. X *  $Header: precision.c,v 3.5 87/08/06 08:10:59 kenj Exp $
  1086. X */
  1087. X
  1088. X#ifdef unix
  1089. X
  1090. X#define SIGNAL
  1091. X
  1092. X#include <sys/signal.h>
  1093. X#include <setjmp.h>
  1094. X
  1095. Xjmp_buf lab;
  1096. Xoverflow(sig) int sig; { /*what to do on overflow*/
  1097. X    signal(sig, overflow);
  1098. X    longjmp(lab, 1);
  1099. X}
  1100. X
  1101. X#endif
  1102. X
  1103. Xint tenlog(v) double v; {
  1104. X    /*The largest power of ten less than v*/
  1105. X    int p=0;
  1106. X    while (v>10) { p++; v/=10; }
  1107. X    return p;
  1108. X}
  1109. X
  1110. Xint two(v) int v; {
  1111. X    /* (the closest power of two to v)-1 */
  1112. X    int t=1, s;
  1113. X    while (t<v) t=t*2+1;
  1114. X    s=(t-1)/2;
  1115. X    if ((v-s)>(t-v)) return(t);
  1116. X    return(s);
  1117. X}
  1118. X
  1119. Xdouble twopower(n, e) int n, *e; {
  1120. X    /* Calculate 2**n without overflow worries */
  1121. X    /* Result is r*10**e */
  1122. X    double r=1.0; *e=0;
  1123. X    while (n-- > 0) {
  1124. X        r*=2.0;
  1125. X        if (r>10.0) { r/=10.0; (*e)++; }
  1126. X    }
  1127. X    return(r);
  1128. X}
  1129. X
  1130. Xmain() {
  1131. X    short maxshort, newshort;
  1132. X    int maxint, newint, i, maxfexp, maxdexp, bits,
  1133. X        fmantis, dmantis, ddmantis,
  1134. X        shortpower, intpower, longpower,
  1135. X        fpower, dpower, fipower, dipower, ddipower, lpower, base;
  1136. X    long maxlong, newlong;
  1137. X    float maxfloat, newfloat, sum, f, maxifloat;
  1138. X    double maxdouble, newdouble, maxidouble, maxiexpr,
  1139. X           d, incr, dsum;
  1140. X
  1141. X#ifdef SIGNAL
  1142. X    signal(SIGFPE, overflow); /*signal(SIGOVER, overflow);*/
  1143. X#endif
  1144. X
  1145. X/****** Calculate max short *********************************************/
  1146. X/*      Calculate 2**n-1 until overflow - then use the previous value    */
  1147. X
  1148. X    newshort=1; maxshort=0;
  1149. X#ifdef SIGNAL
  1150. X    if (setjmp(lab)==0)
  1151. X#endif
  1152. X    for(shortpower=0; newshort>maxshort; shortpower++) {
  1153. X        maxshort=newshort;
  1154. X        newshort=newshort*2+1;
  1155. X    }
  1156. X    bits= (shortpower+1)/sizeof(short);
  1157. X    printf("maxshort=%d (=2**%d-1)\n", maxshort, shortpower);
  1158. X
  1159. X/****** Calculate max int by the same method ***************************/
  1160. X
  1161. X    newint=1; maxint=0;
  1162. X#ifdef SIGNAL
  1163. X    if (setjmp(lab)==0)
  1164. X#endif
  1165. X    for(intpower=0; newint>maxint; intpower++) {
  1166. X        maxint=newint;
  1167. X        newint=newint*2+1;
  1168. X    }
  1169. X    printf("maxint=%d (=2**%d-1)\n", maxint, intpower);
  1170. X
  1171. X/****** Calculate max long by the same method ***************************/
  1172. X
  1173. X    newlong=1; maxlong=0;
  1174. X#ifdef SIGNAL
  1175. X    if (setjmp(lab)==0)
  1176. X#endif
  1177. X    for(longpower=0; newlong>maxlong; longpower++) {
  1178. X        maxlong=newlong;
  1179. X        newlong=newlong*2+1;
  1180. X    }
  1181. X    printf("maxlong=%ld (=2**%d-1)\n", maxlong, longpower);
  1182. X
  1183. X/****** Calculate max float, assuming it's a power of two ***************/
  1184. X/*    Calculate 2**i until it overflows, and then use the nearest    */
  1185. X/*    power of two (some machines overflow early, some late)        */
  1186. X
  1187. X    newfloat=1; maxfloat=0;
  1188. X#ifdef SIGNAL
  1189. X    if (setjmp(lab)==0)
  1190. X#endif
  1191. X    for(i=0;newfloat>maxfloat;i++) {
  1192. X        maxfloat=newfloat;
  1193. X        newfloat=newfloat*2;
  1194. X    }
  1195. X    maxfexp=two(i); maxfloat=twopower(maxfexp, &fpower);
  1196. X    printf("maxfloat=~%fE%d (=~2**%d) (%d bits)\n",
  1197. X            maxfloat, fpower, maxfexp, sizeof(float)*bits);
  1198. X
  1199. X/****** Calculate max double, assuming it's a power of two **************/
  1200. X
  1201. X    newdouble=1; maxdouble=0;
  1202. X#ifdef SIGNAL
  1203. X    if (setjmp(lab)==0)
  1204. X#endif
  1205. X    for(i=0;newdouble>maxdouble;i++) {
  1206. X        maxdouble=newdouble;
  1207. X        newdouble*=2;
  1208. X    }
  1209. X#ifdef SIGNAL
  1210. X    if (setjmp(lab)!=0) { printf("\nUnexpected overflow\n"); exit(1); }
  1211. X#endif
  1212. X    maxdexp=two(i); maxdouble=twopower(maxdexp, &dpower);
  1213. X    printf("maxdouble=~%fE%d (=~2**%d) (%d bits)\n",
  1214. X            maxdouble, dpower, maxdexp, sizeof(double)*bits);
  1215. X
  1216. X/****** Calculate the accuracy for float, double, and expressions *******/
  1217. X/*    maxintfloat and maxintdouble are the largest values that can    */
  1218. X/*    still be integer values; ie such that (x+1)-x=1.        */
  1219. X/*    Some systems really do use extra precision in expressions    */
  1220. X
  1221. X    f=2.0; incr=1.0; sum=f+incr;
  1222. X    for (fmantis=0; sum>2.0; fmantis++) { incr/=2; sum=f+incr; }
  1223. X    printf("max float exp=%d mantissa bits=%d\n", maxfexp, fmantis);
  1224. X
  1225. X    d=2.0; incr=1.0; dsum=d+incr;
  1226. X    for (dmantis=0; dsum>2.0; dmantis++) { incr/=2; dsum=d+incr; }
  1227. X    printf("max double exp=%d mantissa bits=%d\n", maxdexp, dmantis);
  1228. X
  1229. X    d=2.0; incr=1.0;
  1230. X    for (ddmantis=0; d+incr>2.0; ddmantis++) incr/=2;
  1231. X
  1232. X    maxifloat=twopower(fmantis, &fipower);
  1233. X    printf("maxintfloat=~%fE%d (=2**%d-1) (%d digit precision)\n",
  1234. X            maxifloat, fipower, fmantis, fipower);
  1235. X
  1236. X    maxidouble=twopower(dmantis, &dipower);
  1237. X    printf("maxintdouble=~%fE%d (=2**%d-1) (%d digit precision)\n",
  1238. X            maxidouble, dipower, dmantis, dipower);
  1239. X
  1240. X    maxiexpr=twopower(ddmantis, &ddipower);
  1241. X    printf("maxint for expressions=~%fE%d (=2**%d-1) (%d digit precision)\n",
  1242. X            maxiexpr, ddipower, ddmantis, ddipower);
  1243. X
  1244. X/****** BASE is the largest power of ten such that BASE*BASE can be    */
  1245. X/*    computed exactly as a double, and BASE+BASE as a long, useful    */
  1246. X/*    for multi-length arithmetic                    */
  1247. X
  1248. X    lpower= tenlog((double)(maxlong/2));
  1249. X    base= (dipower/2)>lpower?lpower:(dipower/2);
  1250. X    printf("BASE=1E%d\n", base);
  1251. X    
  1252. X    exit(0);
  1253. X}
  1254. End-of-File-Grunt
  1255. if test 5003 -ne `cat 'precision.c' | wc -c`
  1256. then
  1257.     echo 'shar: transmission error (expected 5003 characters)'
  1258. fi
  1259. echo 'x - run'
  1260. if test -f 'run'
  1261. then
  1262.     echo 'shar: over-writing existing file run'
  1263. fi
  1264. sed 's/^X//' > run <<'End-of-File-Grunt'
  1265. X#! /bin/sh
  1266. Xversion="5.0"
  1267. X#
  1268. X# General Purpose Benchmark
  1269. X# Ken McDonell, Computer Science, Monash University
  1270. X# August 1, 1983
  1271. X#
  1272. X# $Header: run,v 3.13 87/09/17 06:09:50 kenj Exp $
  1273. X#
  1274. X#  You will need ...
  1275. X#    Level 7 shell
  1276. X#    awk cat cc chmod comm cp date dc df echo ed expr
  1277. X#    kill ls make mkdir rm sed test time touch tty who
  1278. X#
  1279. X#  The following variables may be assigned external values to overide defaults
  1280. X#
  1281. X#    Test        Variable    Default        Use
  1282. X#    all        iterations    6        repeat count for timing
  1283. X#    arithmetic    arithloop    1000        no. of summations
  1284. X#    hanoi        ndisk        17        list of nos. of disks
  1285. X#    syscall        ncall        4000        no. iterations, each of
  1286. X#                            5 system calls
  1287. X#    context1    switch1        500        no. of switches
  1288. X#    pipe        io        2048        no. 512 byte blocks to
  1289. X#                            read and write
  1290. X#    spawn        children    100        no. of child processes
  1291. X#    execl        nexecs        100        no. of execs
  1292. X#    randmem,seqmem    arrays        8 64 512    list or array sizes
  1293. X#            poke        100000        no. array accesses
  1294. X#    fstime        blocks        62 125 250 500    list of file sizes
  1295. X#            where        .        directory for files
  1296. X#                            need 2 x max[ $blocks ]
  1297. X#    work        nusers        1 4 8 16 24 32     list of nos. of users
  1298. X#            rate        2        per user input rate
  1299. X#                            [ chars / sec ]
  1300. X#            ttys        /dev/tty    list of devices where
  1301. X#                            output goes
  1302. X#            dirs        .        list of directories for
  1303. X#                            creation of temp work
  1304. X#
  1305. Xif make source install
  1306. Xthen
  1307. X    :
  1308. Xelse
  1309. X    echo "run: something is very wrong here .. initial make failed"
  1310. X    exit 1
  1311. Xfi
  1312. Xecho "kill -9 $$" > Tmp/kill_run ; chmod u+x Tmp/kill_run
  1313. Xif test $# -eq 0
  1314. Xthen
  1315. X    set -    arithoh register short int long float double dc hanoi \
  1316. X        syscall pipe context1 spawn execl \
  1317. X        C seqmem randmem fstime work
  1318. Xelif test "$1" = "arithmetic"
  1319. Xthen
  1320. X    set -    arithoh register short int long float double dc
  1321. Xfi
  1322. Xiter=${iterations-6}
  1323. Xdate=`date`
  1324. Xtmp=Tmp/$$.tmp
  1325. Xlog=Results/log
  1326. Xlogwork=Results/log.work
  1327. Xecho "" >>$log
  1328. Xecho "Start Benchmark Run (MUSBUS Version $version)" >>$log
  1329. Xecho "  $date (long iterations $iter times)" >>$log
  1330. Xecho " " `who | wc -l` "interactive users." >>$log
  1331. Xif test $iter -eq 6
  1332. Xthen
  1333. X    longloop="1 2 3 4 5 6"
  1334. X    shortloop="1 2 3"
  1335. Xelse
  1336. X    short=`expr \( $iter + 1 \) / 2`
  1337. X    longloop=""
  1338. X    shortloop=""
  1339. X    while test $iter -gt 0
  1340. X    do
  1341. X        longloop="$iter $longloop"
  1342. X        if test $iter -le $short
  1343. X        then
  1344. X            shortloop="$iter $shortloop"
  1345. X        fi
  1346. X        iter=`expr $iter - 1`
  1347. X    done
  1348. Xfi
  1349. Xif test ! -f iamalive
  1350. Xthen
  1351. X    make iamalive
  1352. Xfi
  1353. Xfor test
  1354. Xdo
  1355. X    need=$test
  1356. X    prog=./$test
  1357. X    paramlist="#"
  1358. X    parammsg=""
  1359. X    repeat="$longloop"
  1360. X    stdout="$log"
  1361. X    stdin=""
  1362. X    cleanopt="-t $tmp"
  1363. X    trap "./cleanup -l $log -a; exit" 1 2 3 15
  1364. X    echo $test:
  1365. X    echo "" >>$log
  1366. X    case $test
  1367. X    in
  1368. X
  1369. X    arithoh|register|short|int|long|float|double)
  1370. X        options=${arithloop-1000}
  1371. X        logmsg="Arithmetic Test (type = $test): $options Iterations"
  1372. X        ;;
  1373. X
  1374. X    dc)     need=dc.dat
  1375. X        prog=dc
  1376. X        options=""
  1377. X        stdin=dc.dat
  1378. X        stdout=/dev/null
  1379. X        logmsg="Arithmetic Test (sqrt(2) with dc to 99 decimal places)"
  1380. X        ;;
  1381. X
  1382. X    hanoi)    options='$param'
  1383. X        stdout=/dev/null
  1384. X        logmsg="Recursion Test: Tower of Hanoi Problem"
  1385. X        paramlist="${ndisk-17}"
  1386. X        parammsg='$param Disk Problem:'
  1387. X        ;;
  1388. X
  1389. X    syscall)
  1390. X        options=${ncall-4000}
  1391. X        logmsg="System Call Overhead Test: 5 x $options Calls"
  1392. X        ;;
  1393. X
  1394. X    context1)
  1395. X        options=${switch1-500}
  1396. X        logmsg="Pipe-based Context Switching Test: 2 x $options Switches"
  1397. X        ;;
  1398. X
  1399. X    pipe)   options=${io-2048}
  1400. X        logmsg="Pipe Throughput Test: read & write $options x 512 byte blocks"
  1401. X        ;;
  1402. X
  1403. X    spawn)  options=${children-100}
  1404. X        logmsg="Process Creation Test: $options forks"
  1405. X        ;;
  1406. X
  1407. X    execl)  options=${nexecs-100}
  1408. X        logmsg="Execl Throughput Test: $options execs"
  1409. X        ;;
  1410. X
  1411. X    randmem|seqmem)
  1412. X        type=Random
  1413. X        if test $test = seqmem
  1414. X        then
  1415. X            type=Sequential
  1416. X        fi
  1417. X        poke=${poke-100000}
  1418. X        options='-s$param '"-n$poke"
  1419. X        logmsg="$type Memory Access Test: $poke Accesses"
  1420. X        paramlist=${arrays-"8 64 512"}
  1421. X        parammsg='Array Size: $param Kbytes'
  1422. X        cleanopt="-m $tmp"
  1423. X        ;;
  1424. X
  1425. X    fstime) repeat="$shortloop"
  1426. X        where=${where-Tmp}
  1427. X        options='$param '"$where"
  1428. X        logmsg="Filesystem Throughput Test:"
  1429. X        paramlist=${blocks-"62 125 250 500"}
  1430. X        parammsg='File Size: $param blocks'
  1431. X        cleanopt="-f $tmp"
  1432. X        ;;
  1433. X
  1434. X    C)      need=cctest.c
  1435. X        prog=cc
  1436. X        options='$param'
  1437. X        stdout=/dev/null
  1438. X        repeat="$shortloop"
  1439. X        logmsg="C Compiler Test:"
  1440. X        paramlist="-c_cctest.c cctest.o"
  1441. X        parammsg='cc $param'
  1442. X        rm -f cctest.o a.out
  1443. X        ;;
  1444. X
  1445. X    work|x)
  1446. X        ttys=${ttys-`tty`}
  1447. X        if test "$ttys" = "not a tty"
  1448. X        then
  1449. X            ttys=/dev/tty
  1450. X        fi
  1451. X        tty=`echo $ttys | sed 's/ .*//'` ; export tty
  1452. X        rate=${rate-2} ; export rate
  1453. X        dirs=${dirs-Tmp}
  1454. X        scripts=`echo Tmp/script.?`
  1455. X        need="makework keyb"
  1456. X        prog=./makework
  1457. X        options='$param'
  1458. X        stdin=Tmp/workload
  1459. X        stdout=`echo $ttys | sed 's/ .*//'`
  1460. X        repeat="$shortloop"
  1461. X        logmsg="Simulated Multi-user Work Load Test:"
  1462. X        paramlist=${nusers-"1 4 8 16 24 32"}
  1463. X        parammsg='$param Concurrent Users, each with Input Keyboard Rate $rate chars / sec'
  1464. X        cleanopt="-w -t $tmp"
  1465. X        maxusers=`echo $paramlist | awk '{for (i=1;i<=NF;i++) if ($i > maxu) maxu=$i; print maxu}'`
  1466. X        if test $test = work
  1467. X        then
  1468. X            ./iamalive "Check job streams and workload description ..."
  1469. X            if make script ttychk clock >/dev/null 2>$tmp
  1470. X            then
  1471. X            :
  1472. X            else
  1473. X            cat $tmp
  1474. X            cat $tmp >>$log
  1475. X            ./cleanup -l $log -r "\"make script\" failed!" -a
  1476. X            exit 1
  1477. X            fi
  1478. X            cmdline=`sed 1q Workload/script.master | sed 's/%W%[     ]*//'`
  1479. X            rm -f Tmp/workload
  1480. X            touch Tmp/workload
  1481. X            ( echo $dirs; echo $scripts; echo $ttys ) \
  1482. X            | awk '
  1483. X            NR==1 { for (i=1;i<=NF;i++) dir[i]=$i;nd=NF }
  1484. X            NR==2 { for (i=1;i<=NF;i++) script[i]=$i;ns=NF }
  1485. X            NR==3 { for (i=1;i<=NF;i++) tty[i]=$i;nt=NF }
  1486. X            END   { for (i=0;i<'$maxusers';i++)
  1487. X                 print dir[i%nd+1] "/user" i " '"$cmdline"' <" script[i%ns+1] " >" tty[i%nt+1] }' \
  1488. X            >>Tmp/workload
  1489. X            echo "done."
  1490. X            ./iamalive "Check tty bandwidth ..."
  1491. X            inch=`cat Tmp/script.1 | wc -c`
  1492. X            outch=`cat Tmp/script.out | wc -c`
  1493. X            nscript=`echo Tmp/script.? | wc -w`
  1494. X            orate=`expr $rate \* $outch / $inch`
  1495. X            if ./ttychk $maxusers $orate $nscript $ttys 2>$tmp
  1496. X            then
  1497. X                echo "OK."
  1498. X            else
  1499. X            echo "FAILED!"
  1500. X            cat $tmp
  1501. X            cat $tmp >>$log
  1502. X            rm -f $tmp
  1503. X            ./cleanup -l $log -a
  1504. X            exit 1
  1505. X            fi
  1506. X        fi
  1507. X        ./iamalive "Set up work directories ..."
  1508. X        cd Workload 
  1509. X            if make context >/dev/null 2>../$tmp
  1510. X        then
  1511. X            cd ..
  1512. X        else
  1513. X            cd ..
  1514. X            cat $tmp
  1515. X            cat $tmp >>$log
  1516. X            rm -f $tmp
  1517. X            ./cleanup -l $log -r "\"make context\" failed in Workload" -a
  1518. X            exit 1
  1519. X        fi
  1520. X        for dir in `sed 's/ .*//' Tmp/workload`
  1521. X        do
  1522. X            rm -rf $dir
  1523. X            mkdir $dir
  1524. X            cp Workload/* $dir
  1525. X        done
  1526. X        echo "done."
  1527. X        echo "" >>$log
  1528. X        echo "Output sent to ... $ttys" >>$log
  1529. X        echo "Directories for temporary files ... $dirs" >>$log
  1530. X        echo "" >>$log
  1531. X        df >>$log
  1532. X        echo "" >>$log
  1533. X        if test $test = work
  1534. X        then
  1535. X            ./iamalive '60 second wallclock accuracy check ...'
  1536. X            echo "SIGALRM check: " `./clock` >>$log
  1537. X            echo "done."
  1538. X        fi
  1539. X        echo "This test generates lots of tty output"
  1540. X        ;;
  1541. X
  1542. X    *)    ./cleanup -l $log -r "run: unknown test \"$test\"" -a
  1543. X        exit 1
  1544. X        ;;
  1545. X    esac
  1546. X    for file in $need
  1547. X    do
  1548. X    if make $need >/dev/null 2>$tmp
  1549. X    then
  1550. X        :
  1551. X    else
  1552. X        cat $tmp
  1553. X        cat $tmp >>$log
  1554. X        rm -f $tmp
  1555. X        ./cleanup -l $log -r "\"make $need\" failed!" -a
  1556. X        exit 1
  1557. X    fi
  1558. X    done
  1559. X    echo "$logmsg" >>$log
  1560. X    for param in $paramlist
  1561. X    do
  1562. X    param=`echo $param | sed 's/_/ /g'`
  1563. X    ./iamalive "   [$param] -"
  1564. X    eval msg='"'$parammsg'"'
  1565. X    eval opt='"'$options'"'
  1566. X    if test "$msg" != ""
  1567. X    then
  1568. X        echo "" >>$log
  1569. X        echo "$msg" >>$log
  1570. X    fi
  1571. X    rm -f $tmp
  1572. X    for i in $repeat
  1573. X    do
  1574. X        trap "./cleanup -l $log -i $i $cleanopt -a; exit" 1 2 3 15
  1575. X        ./iamalive $i
  1576. X        if test "$stdin" = ""
  1577. X        then
  1578. X        time $prog $opt 2>>$tmp >>$stdout
  1579. X        else
  1580. X        time $prog $opt <$stdin 2>>$tmp >>$stdout
  1581. X        fi
  1582. X        status=$?
  1583. X        if test $status != 0
  1584. X        then
  1585. X        if test -f $tmp
  1586. X        then
  1587. X            cp $tmp Tmp/save.$test.$param
  1588. X            ./cleanup -l $log -i $i $cleanopt -r "run: test=$test param=$param fatalstatus=$status" -a
  1589. X        else
  1590. X            ./cleanup -l $log -r "run: test=$test param=$param fatalstatus=$status" -a
  1591. X        fi
  1592. X        exit
  1593. X        fi
  1594. X        test $prog = makework && ./cleanup -w
  1595. X    done
  1596. X    ./cleanup -l $log $cleanopt
  1597. X    done
  1598. X    case $test
  1599. X    in
  1600. X    C)
  1601. X        rm -f cctest.o a.out
  1602. X        ;;
  1603. X    work|x)
  1604. X        echo "Check for corpses ... " >>$logwork
  1605. X        if test "`echo Tmp/*.tmp`" != 'Tmp/*.tmp'
  1606. X        then
  1607. X        echo "Unclaimed temporary workfiles?" >>$logwork
  1608. X        ls -l Tmp/*.tmp >>$logwork
  1609. X        fi
  1610. X        ( cd Workload ; ls ) >/tmp/work$$
  1611. X        for dir in `sed 's/ .*//' Tmp/workload`
  1612. X        do
  1613. X        ( cd $dir ; ls ) >/tmp/user$$
  1614. X        comm -23 /tmp/work$$ /tmp/user$$ >/tmp/x$$
  1615. X        if test -s /tmp/x$$
  1616. X        then
  1617. X            echo "Files missing from $dir ..." >>$logwork
  1618. X            echo "   " `cat /tmp/x$$` >>$logwork
  1619. X        fi
  1620. X        comm -13 /tmp/work$$ /tmp/user$$ >/tmp/x$$
  1621. X        if test -s /tmp/x$$
  1622. X        then
  1623. X            echo "Extra files in $dir ..." >>$logwork
  1624. X            echo "   " `cat /tmp/x$$` >>$logwork
  1625. X        fi
  1626. X        rm -rf $dir
  1627. X        done
  1628. X        rm -f /tmp/*$$
  1629. X        ;;
  1630. X    esac
  1631. X    echo ""
  1632. Xdone
  1633. Xecho "" >>$log
  1634. Xecho " " `who | wc -l` "interactive users." >>$log
  1635. Xecho "End Benchmark Run ($date) ...." >>$log
  1636. Xecho "End Benchmark Run ($date) ...."
  1637. Xexit
  1638. End-of-File-Grunt
  1639. if test 9021 -ne `cat 'run' | wc -c`
  1640. then
  1641.     echo 'shar: transmission error (expected 9021 characters)'
  1642. fi
  1643. echo 'x - script.master'
  1644. if test -f 'script.master'
  1645. then
  1646.     echo 'shar: over-writing existing file script.master'
  1647. fi
  1648. sed 's/^X//' > script.master <<'End-of-File-Grunt'
  1649. X%W% /bin/sh -ie
  1650. Xmkdir /tmp/$$ tmp
  1651. X%% 1 edit
  1652. X./keyb edscr1.dat | ed edit.dat
  1653. X: .......................................................
  1654. X: .    This is some filler of about the same            .
  1655. X: .    size as the file edscr1.dat, since the           .
  1656. X: .    emulated input proceeds in parallel, and         .
  1657. X: .    we want the real-time delay to be about right    .
  1658. X: .......................................................
  1659. Xchmod u+w temporary
  1660. Xrm temporary
  1661. X%% 2 ls
  1662. Xls -l
  1663. X%% 3 cat
  1664. Xcat cat.dat
  1665. X%% 4 compile
  1666. Xcc -c cctest.c 1>&2
  1667. Xrm *.o
  1668. X%% 5 edit, compile and link
  1669. Xchmod 444 dummy.c
  1670. X./keyb edscr2.dat | ed dummy.c
  1671. X: .  more textual and time filler for the second edscript file, edscr2.dat .
  1672. Xcc dummy.c 1>&2
  1673. Xrm a.* grunt.c
  1674. X%% 6 grep
  1675. Xgrep '[     ]*nwork' grep.dat
  1676. X%% 7 file copying
  1677. Xcp *.c edit.dat /tmp/$$
  1678. Xcp /tmp/$$/* tmp
  1679. X%%
  1680. Xrm -rf tmp /tmp/$$
  1681. End-of-File-Grunt
  1682. if test 835 -ne `cat 'script.master' | wc -c`
  1683. then
  1684.     echo 'shar: transmission error (expected 835 characters)'
  1685. fi
  1686. echo 'x - spawn.c'
  1687. if test -f 'spawn.c'
  1688. then
  1689.     echo 'shar: over-writing existing file spawn.c'
  1690. fi
  1691. sed 's/^X//' > spawn.c <<'End-of-File-Grunt'
  1692. X/*
  1693. X *  Process creation
  1694. X *
  1695. X *  $Header: spawn.c,v 3.4 87/06/22 14:32:48 kjmcdonell Beta $
  1696. X */
  1697. X
  1698. Xmain(argc, argv)
  1699. Xint    argc;
  1700. Xchar    *argv[];
  1701. X{
  1702. X    int    iter;
  1703. X    int    slave;
  1704. X    int    status;
  1705. X
  1706. X    if (argc != 2) {
  1707. X        printf("Usage: %s count\n", argv[0]);
  1708. X        exit(1);
  1709. X    }
  1710. X
  1711. X    iter = atoi(argv[1]);
  1712. X
  1713. X    while (iter-- > 0) {
  1714. X        if ((slave = fork()) == 0) {
  1715. X            /* slave .. boring */
  1716. X#if debug
  1717. X            printf("fork OK\n");
  1718. X#endif
  1719. X            exit(0);
  1720. X        } else if (slave < 0) {
  1721. X            /* woops ... */
  1722. X            printf("Fork failed at iteration %d\n", iter);
  1723. X            perror("Reason");
  1724. X            exit(2);
  1725. X        } else
  1726. X            wait(&status);
  1727. X        if (status != 0) {
  1728. X            printf("Bad wait status: 0x%x\n", status);
  1729. X            exit(2);
  1730. X        }
  1731. X#if debug
  1732. X        printf("Child %d done.\n", slave);
  1733. X#endif
  1734. X    }
  1735. X    exit(0);
  1736. X}
  1737. End-of-File-Grunt
  1738. if test 710 -ne `cat 'spawn.c' | wc -c`
  1739. then
  1740.     echo 'shar: transmission error (expected 710 characters)'
  1741. fi
  1742. echo 'x - syscall.c'
  1743. if test -f 'syscall.c'
  1744. then
  1745.     echo 'shar: over-writing existing file syscall.c'
  1746. fi
  1747. sed 's/^X//' > syscall.c <<'End-of-File-Grunt'
  1748. X/*
  1749. X *  syscall  -- sit in a loop calling the system
  1750. X *
  1751. X *  $Header: syscall.c,v 3.4 87/06/22 14:32:54 kjmcdonell Beta $
  1752. X */
  1753. X
  1754. Xmain(argc, argv)
  1755. Xint    argc;
  1756. Xchar    *argv[];
  1757. X{
  1758. X    int    iter;
  1759. X    int    i;
  1760. X
  1761. X    if (argc != 2) {
  1762. X        printf("Usage: %s count\n", argv[0]);
  1763. X        exit(1);
  1764. X    }
  1765. X
  1766. X    iter = atoi(argv[1]);
  1767. X
  1768. X    while (iter-- > 0) {
  1769. X        close(dup(0));
  1770. X        getpid();
  1771. X        getuid();
  1772. X        umask(022);
  1773. X    }
  1774. X    exit(0);
  1775. X}
  1776. End-of-File-Grunt
  1777. if test 377 -ne `cat 'syscall.c' | wc -c`
  1778. then
  1779.     echo 'shar: transmission error (expected 377 characters)'
  1780. fi
  1781. echo 'x - tbl.1'
  1782. if test -f 'tbl.1'
  1783. then
  1784.     echo 'shar: over-writing existing file tbl.1'
  1785. fi
  1786. sed 's/^X//' > tbl.1 <<'End-of-File-Grunt'
  1787. X.(b
  1788. X.TS
  1789. Xbox,center;
  1790. Xc s s
  1791. Xc | c | c
  1792. Xc | c | c
  1793. Xl | n | n.
  1794. XRaw Speed
  1795. X_
  1796. X    Elapsed    CPU
  1797. XTest Description    Time    Time
  1798. X_
  1799. End-of-File-Grunt
  1800. if test 111 -ne `cat 'tbl.1' | wc -c`
  1801. then
  1802.     echo 'shar: transmission error (expected 111 characters)'
  1803. fi
  1804. echo 'x - tbl.2'
  1805. if test -f 'tbl.2'
  1806. then
  1807.     echo 'shar: over-writing existing file tbl.2'
  1808. fi
  1809. sed 's/^X//' > tbl.2 <<'End-of-File-Grunt'
  1810. X.(b
  1811. X.TS
  1812. Xbox,center;
  1813. Xc s s.
  1814. XMemory Throughput
  1815. X(1000s integer accesses per sec.)
  1816. X_
  1817. X.T&
  1818. Xc | c | c
  1819. Xc | c | c
  1820. Xn | n | n.
  1821. XArray Size
  1822. X(K bytes)    Sequential    Random
  1823. X_
  1824. End-of-File-Grunt
  1825. if test 157 -ne `cat 'tbl.2' | wc -c`
  1826. then
  1827.     echo 'shar: transmission error (expected 157 characters)'
  1828. fi
  1829. echo 'x - tbl.3'
  1830. if test -f 'tbl.3'
  1831. then
  1832.     echo 'shar: over-writing existing file tbl.3'
  1833. fi
  1834. sed 's/^X//' > tbl.3 <<'End-of-File-Grunt'
  1835. X.(b
  1836. X.TS
  1837. Xbox,center;
  1838. Xc s s s.
  1839. XFilesystem Throughput (Kchars per sec.)
  1840. End-of-File-Grunt
  1841. if test 69 -ne `cat 'tbl.3' | wc -c`
  1842. then
  1843.     echo 'shar: transmission error (expected 69 characters)'
  1844. fi
  1845. echo 'x - tbl.4'
  1846. if test -f 'tbl.4'
  1847. then
  1848.     echo 'shar: over-writing existing file tbl.4'
  1849. fi
  1850. sed 's/^X//' > tbl.4 <<'End-of-File-Grunt'
  1851. X_
  1852. X.T&
  1853. Xc | c | c | c
  1854. Xl | n | n | n.
  1855. XFile Size    Write    Read    Copy
  1856. X_
  1857. End-of-File-Grunt
  1858. if test 63 -ne `cat 'tbl.4' | wc -c`
  1859. then
  1860.     echo 'shar: transmission error (expected 63 characters)'
  1861. fi
  1862. echo 'x - tbl.5'
  1863. if test -f 'tbl.5'
  1864. then
  1865.     echo 'shar: over-writing existing file tbl.5'
  1866. fi
  1867. sed 's/^X//' > tbl.5 <<'End-of-File-Grunt'
  1868. X.(b
  1869. X.TS
  1870. Xbox,center;
  1871. Xc s s
  1872. Xc | c | c
  1873. Xn | n | n.
  1874. XSimulated Work Load
  1875. X_
  1876. XUsers    Elapsed Time    CPU Time
  1877. X_
  1878. End-of-File-Grunt
  1879. if test 99 -ne `cat 'tbl.5' | wc -c`
  1880. then
  1881.     echo 'shar: transmission error (expected 99 characters)'
  1882. fi
  1883. echo 'x - time.awk'
  1884. if test -f 'time.awk'
  1885. then
  1886.     echo 'shar: over-writing existing file time.awk'
  1887. fi
  1888. sed 's/^X//' > time.awk <<'End-of-File-Grunt'
  1889. X# $Header: time.awk,v 3.4 87/06/22 14:28:09 kjmcdonell Beta $
  1890. X/real/    { if (!fail) {
  1891. X        real+=$1; r2+=$1*$1; user+=$3; sys+=$5; c=$3+$5; c2+=c*c
  1892. X        ok++
  1893. X      }
  1894. X          iter++; fail=0; next
  1895. X    }
  1896. X    { print "** Iteration ",iter+1," Failed: ",$0; fail=1 }
  1897. XEND {
  1898. X    if (fail) iter++
  1899. X    if (ok != iter) {
  1900. X        printf "For %d successful iterations from %d attempts ...\n",ok,iter
  1901. X        iter=ok
  1902. X    }
  1903. X    if (iter > 0) {
  1904. X        printf "Elapsed Time: %.2f seconds",real/iter
  1905. X        if (iter > 1) printf " (variance %.3f)",(r2-2*real*real/iter+real*real/iter)/(iter-1)
  1906. X        cpu=sys+user
  1907. X        printf "\nCPU Time: %.2f seconds [ %.2fu + %.2fs ]",cpu/iter,user/iter,sys/iter
  1908. X        if (iter > 1) printf " (variance %.3f)",(c2-2*cpu*cpu/iter+cpu*cpu/iter)/(iter-1)
  1909. X        print
  1910. X    } else {
  1911. X        print "Elapsed Time: -- no measured results!!"
  1912. X        print "CPU Time: -- no measured results!!"
  1913. X    }
  1914. X    }
  1915. End-of-File-Grunt
  1916. if test 864 -ne `cat 'time.awk' | wc -c`
  1917. then
  1918.     echo 'shar: transmission error (expected 864 characters)'
  1919. fi
  1920. echo 'x - ttychk.c'
  1921. if test -f 'ttychk.c'
  1922. then
  1923.     echo 'shar: over-writing existing file ttychk.c'
  1924. fi
  1925. sed 's/^X//' > ttychk.c <<'End-of-File-Grunt'
  1926. X/*
  1927. X *
  1928. X * Checks for tty accessability and bandwidth saturation.
  1929. X *
  1930. X * $Header: ttychk.c,v 3.6 87/06/22 14:32:58 kjmcdonell Beta $
  1931. X */
  1932. X
  1933. X#include <stdio.h>
  1934. X#include <sgtty.h>
  1935. X#include <signal.h>
  1936. X
  1937. Xstruct {
  1938. X    int    baud;    /* baud rate */
  1939. X    int    symb;    /* symbolic constant for baud rate */
  1940. X} bmap[] = {
  1941. X    {  300,  B300 },
  1942. X    { 1200, B1200 },
  1943. X    { 2400, B2400 },
  1944. X    { 4800, B4800 },
  1945. X    { 9600, B9600 },
  1946. X    {    0,     0 }
  1947. X};
  1948. Xint        status = 0;    /* exit() status */
  1949. X
  1950. Xmain(argc, argv)
  1951. Xint    argc;
  1952. Xchar    *argv[];
  1953. X{
  1954. X    struct sgttyb    ttyb;
  1955. X    int        nusers;        /* number of simulated users */
  1956. X    int        nscript;    /* number of script files */
  1957. X    int        baud = 0;    /* aggregate baud rate across
  1958. X                       active ttys */
  1959. X    int        br;
  1960. X    int        nttys;        /* number of active ttys */
  1961. X    int        i;
  1962. X    int        fd;
  1963. X    int        l;
  1964. X    float        orate;        /* estimated output rate per user */
  1965. X        int        onalarm();
  1966. X
  1967. X    if (argc < 5) {
  1968. X        fprintf(stderr, "Usage: ttychk nusers orate nscript ttydev ... \n");
  1969. X        exit(1);
  1970. X    }
  1971. X    nusers = atoi(argv[1]);
  1972. X    if (nusers < 1) {
  1973. X        fprintf(stderr, "ttychk: nusers must be > 0\n");
  1974. X        status |= 1;
  1975. X    }
  1976. X    sscanf(argv[2], "%f", &orate);
  1977. X    nscript = atoi(argv[3]);
  1978. X    if (nscript < 1) {
  1979. X        fprintf(stderr, "ttychk: nscript must be > 0\n");
  1980. X        status |= 1;
  1981. X    }
  1982. X
  1983. X    nttys = nusers <= nscript ? nusers : nscript;
  1984. X
  1985. X    signal(SIGALRM, onalarm);
  1986. X    for (i = 4; i < argc && nttys; i++, nttys--) {
  1987. X        alarm(3);
  1988. X        if ((fd = open(argv[i], 1)) < 0) {
  1989. X            fprintf(stderr, "ttychk: cannot open %s for writing\n",
  1990. X                argv[i]);
  1991. X            perror("");
  1992. X            status |= 1;
  1993. X            continue;
  1994. X        }
  1995. X        alarm(0);
  1996. X        if (ioctl(fd, TIOCGETP, &ttyb) < 0) {
  1997. X            fprintf(stderr, "ttychk: cannot stat %s\n",
  1998. X                argv[i]);
  1999. X            perror("");
  2000. X            status |= 1;
  2001. X            close(fd);
  2002. X            continue;
  2003. X        }
  2004. X        close(fd);
  2005. X        br = 0;
  2006. X        for (l = 0; bmap[l].baud; l++) {
  2007. X            if (bmap[l].symb == ttyb.sg_ospeed) {
  2008. X                br = bmap[l].baud;
  2009. X                break;
  2010. X            }
  2011. X        }
  2012. X#ifdef DEBUG
  2013. X        fprintf(stderr, "%s: %d baud\n", argv[i], br);
  2014. X#endif
  2015. X        if (br != 9600)
  2016. X            fprintf(stderr, "ttychk: Warning - baud rate at %d for %s\n",
  2017. X                br, argv[i]);
  2018. X        baud += br;
  2019. X    }
  2020. X    nttys = nusers <= nscript ? nusers : nscript;
  2021. X#ifdef DEBUG
  2022. X    fprintf(stderr, "aggregate tty bandwidth: %d baud\n", baud);
  2023. X    fprintf(stderr, "aggregate tty output rate: %d chars/sec (for %d ttys)\n", (int)(orate*nusers), nttys);
  2024. X#endif
  2025. X
  2026. X    /* assume 10 bits per character, and the 50% figure is arbitrary! */
  2027. X    if (nusers*orate > 0.5*(baud/10)) {
  2028. X        fprintf(stderr, "ttychk panic: Total tty output rate (%d chars/sec) exceeds 50%% of\n              total tty bandwidth (%d chars/sec)\n",
  2029. X            (int)(nusers*orate), baud/10);
  2030. X        status |= 1;
  2031. X    }
  2032. X
  2033. X    exit(status);
  2034. X}
  2035. X
  2036. Xonalarm()
  2037. X{
  2038. X    status |= 1;
  2039. X}
  2040. End-of-File-Grunt
  2041. if test 2564 -ne `cat 'ttychk.c' | wc -c`
  2042. then
  2043.     echo 'shar: transmission error (expected 2564 characters)'
  2044. fi
  2045. echo 'x - util.c'
  2046. if test -f 'util.c'
  2047. then
  2048.     echo 'shar: over-writing existing file util.c'
  2049. fi
  2050. sed 's/^X//' > util.c <<'End-of-File-Grunt'
  2051. X#include "makework.h"
  2052. X#ifndef lint
  2053. Xstatic char RCSid[] = "$Header: util.c,v 1.3 87/06/23 15:56:41 kjmcdonell Beta $";
  2054. X#endif
  2055. X
  2056. Xfatal(s)
  2057. Xchar *s;
  2058. X{
  2059. X    int    i;
  2060. X    fprintf(stderr, s);
  2061. X    fflush(stderr);
  2062. X    perror("Reason?");
  2063. X    fflush(stderr);
  2064. X    for (i = 0; i < nstream; i++) {
  2065. X    if (work[i].pid > 0 && kill(work[i].pid, SIGKILL) != -1) {
  2066. X        fprintf(stderr, "pid %d killed off\n", work[i].pid);
  2067. X        fflush(stderr);
  2068. X    }
  2069. X    }
  2070. X    exit_status = 4;
  2071. X    return;
  2072. X}
  2073. X
  2074. X#ifdef DEBUG
  2075. Xdumpwork()
  2076. X{
  2077. X    int        i;
  2078. X    int        j;
  2079. X
  2080. X    for (i = 0; i < nstream; i++) {
  2081. X    fprintf(stderr, "job %d: cmd: %s home: %s tty: %s\n",
  2082. X        i, work[i].cmd, work[i].home, work[i].tty);
  2083. X    j = 0;
  2084. X    while (work[i].av[j]) {
  2085. X        fprintf(stderr, "argv[%d]: %s\n", j, work[i].av[j]);
  2086. X        j++;
  2087. X    }
  2088. X    fprintf(stderr, "input: %d chars text: ", work[i].blen);
  2089. X    if (work[i].buf == (char *)0)
  2090. X        fprintf(stderr, "<NULL>\n");
  2091. X    else {
  2092. X            register char    *pend;
  2093. X            char        *p;
  2094. X        char        c;
  2095. X        p = work[i].buf;
  2096. X        while (*p) {
  2097. X            pend = p;
  2098. X            while (*pend && *pend != '\n')
  2099. X                pend++;
  2100. X            c = *pend;
  2101. X            *pend = '\0';
  2102. X            fprintf(stderr, "%s\n", p);
  2103. X            *pend = c;
  2104. X            p = &pend[1];
  2105. X        }
  2106. X    }
  2107. X    }
  2108. X}
  2109. X#endif
  2110. End-of-File-Grunt
  2111. if test 1146 -ne `cat 'util.c' | wc -c`
  2112. then
  2113.     echo 'shar: transmission error (expected 1146 characters)'
  2114. fi
  2115.